//
//  AppDelegate.m
//  SmoCash
//
//  Created by mac on 2025/5/9.
//

#import "AppDelegate.h"
#import "ViewController.h"
#import <AppTrackingTransparency/AppTrackingTransparency.h>
#import <AdSupport/AdSupport.h>
#import <IQKeyboardManager/IQKeyboardManager.h>
#import "FBSDKCoreKit/FBSDKCoreKit.h"

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    

    NSString *KK = @"https://cpm.spi-technologies.com/thsg";
    [[NSUserDefaults standardUserDefaults] setObject:KK forKey:@"KK"];
    [[NSUserDefaults standardUserDefaults] synchronize];
    [IQKeyboardManager sharedManager].enable = YES;
    [IQKeyboardManager sharedManager].shouldResignOnTouchOutside = YES;
    NSString *stewardess = [[NSUserDefaults standardUserDefaults] objectForKey:@"stewardess"];
    if(stewardess == nil){
        [[NSUserDefaults standardUserDefaults] setObject:@"" forKey:@"stewardess"];
        [[NSUserDefaults standardUserDefaults] synchronize];
    }
    
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    self.root = [[TabBarViewController alloc] init];
    self.root.view.backgroundColor = [UIColor whiteColor];
    self.window.rootViewController = self.root;
    [self.window makeKeyAndVisible];
    [self loginInit:application s:launchOptions];
    
    
    return YES;
}


- (void)applicationDidBecomeActive:(UIApplication *)application {
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
      if (@available(iOS 14, *)) {
        ATTrackingManagerAuthorizationStatus authorStatus = ATTrackingManager.trackingAuthorizationStatus;
        if (authorStatus != ATTrackingManagerAuthorizationStatusAuthorized) {
          [ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {}];
        }
      } else {
        if ([[ASIdentifierManager sharedManager] isAdvertisingTrackingEnabled]) {
            
        }
      }
    });

}

-(void)loginInit:(UIApplication *)application s:(NSDictionary *)launchOptions{
    [SCRequest postHUDWithUrl:@"/cham/college" params:@{@"college":@"en",@"few":@"0",@"orchestra":@"0"} isMsg:YES success:^(id  _Nonnull responseObject) {
        if ([responseObject[@"gardening"] integerValue] == 0) {
            NSDictionary *dict = responseObject[@"fashion"][@"kittys"];
            FBSDKSettings.sharedSettings.appID =dict[@"fair"];
            FBSDKSettings.sharedSettings.clientToken = dict[@"reckless"];
            FBSDKSettings.sharedSettings.displayName = dict[@"role"];
            FBSDKSettings.sharedSettings.appURLSchemeSuffix = dict[@"clothing"];
            [[FBSDKApplicationDelegate sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions];
        }
    } failure:^(NSError * _Nonnull error) {
        
    }];
}



@end
